


$(function(){
	getIndex();
});
var baseurl = 'http://kt.zhangzhengjiang.top/api/';
var static_url = 'http://kt.zhangzhengjiang.top/';
function getIndex(){
		 layer.open({
		    type: 2
		    ,content: '正在加载...'
		  });
		$.ajax({
			url:baseurl+'index/index',
			type:'post',
			async:false,
			success:function(res){
				layer.closeAll();
				console.log(res);
				if(res.code == 1){
				  //轮播
				  var banner = res.data.banner;
				  var banner_html = '<div class="swiper-wrapper">';
				  for (var i = 0; i < banner.length; i++) {
						banner_html+='<div class="swiper-slide">';
							banner_html+='<a href="'+banner[i].url+'"><img src="'+static_url+banner[i].image+'" /></a>';
						banner_html+='</div>';
				  		//banner_html+='<li style="display: table-cell; vertical-align: top; width: 375px;"><img src=""/></li>';
				  	
				  }
				  banner_html+='</div>';
				  $('#banner').html(banner_html);
				  var mySwiper = new Swiper('.top_banner', {
					slidesPerView: 'auto',
	                  centeredSlides: true,
	  
	                  watchSlidesProgress: true,
	  
	                  paginationClickable: true,
	                  slidesPerView: 1.1,
	                  spaceBetween: 10,
	                  loop: true,
	                  autoplay: true	            
				 });
				  
				  // //活动
				  var tougao = res.data.tougao;
				  var tougao_html = '';
				  for (var i = 0; i < tougao.length; i++) {
						tougao_html+='<li class="tab-head-item aui-position-relative">';
							var num = parseInt(i)+parseInt(1);
							tougao_html+='<span class="rank-num aui-position-absolute">'+num+'</span>';
							tougao_html+='<div class="aui-col-imgs">';
								tougao_html+='<a href="textList.html">';
									tougao_html+='<img src="'+static_url+tougao[i].avatar+'" alt="" class="aui-iconfont aui-imgs">';
									tougao_html+='<p class="aui-font-size-12 aui-ellipsis-1 aui-text-gray aui-margin-t-5 trans-eight">'+tougao[i].nickname+'</p>';
									tougao_html+='<p class="aui-color-three aui-font-size-14 aui-font-weight aui-ellipsis-1">'+tougao[i].title+'</p>';
									tougao_html+='<div class="aui-grid-label aui-font-size-13 aui-laud-num">';
										tougao_html+='<i class="aui-iconfont aui-icon-laud"></i>';
										tougao_html+='<span class="aui-font-size-12 trans-eight">'+tougao[i].praise+'</span>';
									tougao_html+='</div>';
								tougao_html+='</a>';
							tougao_html+='</div>';
						tougao_html+='</li>';
				  }
				  
				  $('#tougao').html(tougao_html);
				  
				  //跟课辅导
				  var gkfd = res.data.kkfd;
				  var gkfd_html = '';
				  for (var i = 0; i < gkfd.length; i++) {
					  gkfd_html+='<a href="classLists.html?kid='+gkfd[i].id+'">';
					  	gkfd_html+='<li class="aui-list-item aui-border-b-0 aui-list-item-middle aui-padded-r-15 aui-background-white">';
					  		gkfd_html+='<div class="aui-media-list-item-inner" style="align-items: center;">';
					  			gkfd_html+='<div class="aui-list-item-media wechat-avatar aui-list-media-img" style="width: 3rem;">';
					  				gkfd_html+='<img src="'+static_url+gkfd[i].images+'">';
					  			gkfd_html+='</div>';
					  			gkfd_html+='<div class="aui-list-item-inner aui-padded-l-10 aui-position-relative" style="height: 4rem;">';
					  				gkfd_html+='<p class="aui-color-three aui-font-size-14">'+gkfd[i].title+'</p>';
					  				gkfd_html+='<p class="aui-font-size-12 aui-ellipsis-1">'+gkfd[i].content+'</p>';
					  				gkfd_html+='<p class="aui-font-size-12 aui-ellipsis-1 aui-position-absolute" style="bottom: 7px;"><span style="color:red;">'+gkfd[i].pay_num+'</span> 人已购买</p>';
					  			gkfd_html+='</div>';
					  			
					  		gkfd_html+='</div>';
					  	gkfd_html+='</li>';
					  gkfd_html+='</a>';
				  		
				  }
				  $('#gkfd').html(gkfd_html);
				  
				  //老师风采
				  var teacher = res.data.teacher;
				  var teacher_html = '';
				  for (var i = 0; i < teacher.length; i++) {
				        teacher_html+='<a href="teacherDetail.html?tid='+teacher[i].id+'">';
				        	 teacher_html+='<li class="aui-list-item aui-border-b-0 aui-list-item-middle aui-padded-r-15 aui-background-white">';
				        		 teacher_html+='<div class="aui-media-list-item-inner" style="align-items: center;">';
				        			 teacher_html+='<div class="aui-list-item-media wechat-avatar aui-list-media-img" style="width: 3rem;">';
				        				 teacher_html+='<img src="'+static_url+teacher[i].image+'">';
				        			 teacher_html+='</div>';
				        			 teacher_html+='<div class="aui-list-item-inner aui-padded-l-10 aui-position-relative" style="height: 4rem;">';
				        				 teacher_html+='<p class="aui-color-three aui-font-size-14">'+teacher[i].name+'</p>';
				        				 teacher_html+='<p class="aui-font-size-12 aui-ellipsis-2">'+teacher[i].content+'</p>';
				        			
				        			 teacher_html+='</div>';
				        			
				        		 teacher_html+='</div>';
				        	 teacher_html+='</li>';
				         teacher_html+='</a>';
				  }
				  $('#teacher').html(teacher_html);
				  //教师课堂
				  var teacherkt = res.data.teacherkt;
				  var teacherkt_html = '';
				  for (var i = 0; i < teacherkt.length; i++) {
				  		teacherkt_html+='<div><a href="classLists.html?kid='+teacherkt[i].id+'">';
				  			teacherkt_html+='<img src="'+static_url+teacherkt[i].images+'" alt="" />';
				  			teacherkt_html+='<p class="aui-font-size-14 aui-text-gray aui-padded-t-10 aui-padded-b-5">'+teacherkt[i].title+'</p>';
				  		teacherkt_html+='</a></div>';
				  }
				  $('#teacherkt').html(teacherkt_html);
				}else{
					layer.open({
						content: res.msg
						,skin: 'msg'
						,time: 2 ,//2秒后自动关闭
						
					});
				}
			}
		})
}
